package cn.centychen.example.spring.cloud.biz.a.config;

import org.springframework.stereotype.Component;

import feign.Response;
import feign.Util;
import feign.codec.ErrorDecoder;
import lombok.extern.slf4j.Slf4j;

/**
 * @program: client-customer
 * @description: fegin异常处理
 * @author: he
 * @create: 2020-07-06 17:35
 **/
@Slf4j
@Component
public class FeignClientErrorDecoder implements ErrorDecoder {


    @Override
    public Exception decode(String s, Response response) {
       log.error(s+"\t"+response.status());
        try {
            String bodyStr= Util.toString(response.body().asReader(Util.UTF_8));
            log.error(bodyStr);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}